"""应用配置
"""
import os
basedir = os.path.abspath(os.path.dirname(__file__))


class Config:
    SECRET_KEY = os.environ.get("SECRET_KEY") or "leo_key_tmp"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    MAIL_SERVER = "smtp.sohu.com"
    MAIL_PORT = 25
    MAIL_USETLS = True
    MAIL_USERNAME = os.environ.get("MAIL_USERNAME")
    MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD")
    MAIL_SUBJECT_PREFIX = "[FlaskSite]"
    MAIL_SENDER = os.environ.get("MAIL_SENDER")
    SYS_ADMIN = os.environ.get("SYS_ADMIN")

    @staticmethod
    def init_app(app):
        pass


class DevConfig(Config):
    ENV = "development"
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = os.environ.get("DEV_DATABASE_URI") \
        or "sqlite:///" + os.path.join(basedir, "data-dev.sqlite")


class ProConfig(Config):
    SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URI") \
        or "sqlite:///" + os.path.join(basedir, "data.sqlite")


class TestConfig(Config):
    TESTING = True
    SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') \
        or 'sqlite://'


config = {
    "development": DevConfig,
    "production": ProConfig,
    "testing": TestConfig,

    "default": ProConfig,
}
